<template>
  <div>
  	  <el-divider></el-divider>
  	  <table  style="margin-top: 0.9375rem; margin-bottom: 20px; " >
  		   <i class="el-icon-search" style="margin-left: 5px;  color: cadetblue;" >筛选查询</i>
  		    <span style="margin-left:80px;">状态:&nbsp;</span>
  		    <el-select v-model="selectHouse.warehouseStatus" style=" width: 100px;" placeholder="请选择">
  		        <el-option label="全部" value=""></el-option>
  		         <el-option label="停用" value="0"></el-option>
  				 <el-option label="启用" value="1"></el-option>
  		     </el-select>
  		      <span  style="margin-left:50px;">模糊查询:&nbsp;</span>
  			  <el-input v-model="selectHouse.warehouseName" style=" width: 100px;" placeholder="门店名称"></el-input>
			  <el-input v-model="selectHouse.warehousePeople" style=" width: 100px;" placeholder="联系人名称"></el-input>
			  <el-input v-model="selectHouse.warehousePhone" style=" width: 100px;" placeholder="手机号"></el-input>
  			  &nbsp; &nbsp; &nbsp; &nbsp;<el-button type="primary" class="el-icon-search" @click="selectAll">查询</el-button>
  	  </table>
	  <table border="0px">
	  	<el-row>
	  		<i class="el-icon-s-grid" style="margin-left: 5px;">数据列表</i>
	  		<el-button type="primary" @click="addHouse=true" style="margin-left: 760px;">新增</el-button>
	  
	  	</el-row>
	  
	  </table>
  	  <el-divider></el-divider>
  	 
    <el-table  :data="tableData" tooltip-effect="dark" style="width: 100%" >
    	
    	<el-table-column prop="warehouseId" label="仓库编号" width="130px">
    	</el-table-column>
    	<el-table-column prop="warehouseName" label="仓库" width="130px">
    	</el-table-column>
    	<el-table-column prop="warehousePeople" label="联系人" width="130px">
    	</el-table-column>
    	<el-table-column prop="warehousePhone" label="手机号" width="130px">
    	</el-table-column>
    	<el-table-column prop="warehouseAddress"  label="地址" width="130px">
    	</el-table-column>
		<el-table-column prop="stores"  label="关联门店" width="130px">
		</el-table-column>
		<el-table-column prop="warehouseStatus"  label="状态" width="130px" :formatter="forcode">
		</el-table-column>
    	<el-table-column prop="name" label="操作" width="250">
    		<template slot-scope="scope">
    			<el-button type="text" @click="updateProper(scope.row)">修改</el-button>
    			<el-button type="text" @click="delHouse(scope.row.warehouseId)">删除</el-button>
    		</template>
    	</el-table-column>
    </el-table>
	<div>
		<el-pagination :current-page="currentPage" @current-change="changePage" background layout="prev, pager, next"
		 :total="total" :page-size="5">
		</el-pagination>
	</div>
	
	
	
	<el-dialog title="新增仓库" :visible.sync="addHouse" @close="clearfrom">
		<el-form :model="addHouseParam" label-width="100px" class="demo-ruleForm">
			<el-row>
				<el-form-item label="仓库名称"  style="width: 400px;">
					<el-input v-model="addHouseParam.warehouseName"></el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="联系人"  style="width: 400px;">
					<el-input v-model="addHouseParam.warehousePeople"></el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="联系人电话"  style="width: 400px;">
					<el-input v-model="addHouseParam.warehousePhone"></el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="地址" style="width: 400px;">
					<el-input v-model="addHouseParam.warehouseAddress"></el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="状态"  style="width: 200px;" >
					<el-select v-model="addHouseParam.warehouseStatus" placeholder="请选择" style="width: 12.5rem" >
						<el-option label="启用" value="0"></el-option>
						<el-option label="停用" value="1"></el-option>
					</el-select>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="门店选择" style="width: 400px;">
				</el-form-item>
			</el-row>
		</el-form>

		<el-transfer
		  filterable
		  v-model="aaa"
		  :data="bigSorts"
		@change="testChange()"
			>
		</el-transfer>

		<div align="center">
			<el-button @click="clearfrom">清空</el-button>
			<el-button type="primary" @click="addProperty">保存</el-button>
		</div>
	
	</el-dialog>
	
	
	
	
	<el-dialog title="修改仓库" :visible.sync="updatehouse" @close="clearfrom">
		<el-form :model="updeteHouseParam" label-width="100px" class="demo-ruleForm">
			<el-row>
				<el-form-item label="编号"  style="width: 400px;">
					<el-input v-model="updeteHouseParam.warehouseId" :disabled="true">{{updeteHouseParam.warehouseId}}</el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="仓库名称"  style="width: 400px;">
					<el-input v-model="updeteHouseParam.warehouseName">{{updeteHouseParam.warehouseName}}</el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="联系人"  style="width: 400px;">
					<el-input v-model="updeteHouseParam.warehousePeople">{{updeteHouseParam.warehousePeople}}</el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="联系人电话"  style="width: 400px;">
					<el-input v-model="updeteHouseParam.warehousePhone">{{updeteHouseParam.warehousePhone}}</el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="地址" style="width: 400px;">
					<el-input v-model="updeteHouseParam.warehouseAddress">{{updeteHouseParam.warehouseAddress}}</el-input>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="状态"  style="width: 200px;">
					<el-select v-model="updeteHouseParam.warehouseStatus" placeholder="请选择" style="width: 12.5rem">
						<el-option label="启用" value="0"></el-option>
						<el-option label="停用" value="1"></el-option>
					</el-select>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="门店选择" style="width: 400px;">
				</el-form-item>
			</el-row>
		</el-form>
	
		<el-transfer
		  filterable
		  v-model="ccc"
		  :data="bigSorts"
		@change="testChange()"
			>
		</el-transfer>
	
		<div align="center">
			<el-button @click="clearfrom">清空</el-button>
			<el-button type="primary" @click="updateWareHouse">保存</el-button>
		</div>
	
	</el-dialog>
	
	
	
	
	
	
	
  	
 
 
  </div>
</template>

<script>
  export default {
    name: "StoreManage",
	data() {
	     return {
			 currentPage:1,
			 total:0,
			 updeteHouseParam:{
				 "warehouseId":null,
				 "warehouseName":null,
				 "warehousePeople":null,
				 "warehousePhone":null,
				 "warehouseAddress":null,				 
				 "warehouseStatus":null,
				 "num":[] 
			 },
			 selectHouse:{
				 warehouseStatus:null,
				 warehouseName:null,
				 warehousePeople:null,
				 warehousePhone:null,
				 pageParam: {
				 	indexPage: 1,
				 	size: 5
				 }
			 },
			 ccc:[],
			 aaa:[],
			 bigSorts:[],
			addHouseParam: {
				warehouseName: null,
				warehousePeople: null,
				warehousePhone: null,
				warehouseAddress: null,
				warehouseStatus:null,
				num:[]
			},
			updatehouse:false,
			addHouse:false,
				  dialogTableVisible: false,
				  dialogFormVisible: false,
				   radio: '3',
				  form:{},
				   forms:{},
	       tableData: [],
	       multipleSelection: []
	     }
	   },
		
	   methods: {
		  
		   changePage(index){
			   this.selectHouse.pageParam.indexPage=index;
			   this.selectAll();
		   },
		  updateWareHouse(){
			  console.log(this.updeteHouseParam)
			  this.updeteHouseParam.num=this.ccc,
			  this.$http.post("/pawnbackgroundsystem/warehouse/updateHouse",this.updeteHouseParam).then(resp=>{
				  if (resp.data.coed == '2002') {
				  	this.$message({
				  		message: '修改成功',
				  		type: 'success'
				  	});
					this.updatehouse=false;
				  	this.selectAll();
				  }
				  
			  })
			  
			  
		  },
		   updateProper(row){
			   this.ccc=[]
			   this.updatehouse=true;
			   this.updeteHouseParam.warehouseId=row.warehouseId;
			   this.updeteHouseParam.warehouseName=row.warehouseName,
			   this.updeteHouseParam.warehousePeople=row.warehousePeople,
			   this.updeteHouseParam.warehousePhone=row.warehousePhone,
			   this.updeteHouseParam.warehouseAddress=row.warehouseAddress,				 
			   this.updeteHouseParam.warehouseStatus=row.warehouseStatus+"",
			   this.updeteHouseParam.num=row.num;
			   this.$http.get("/pawnbackgroundsystem/warehouse/getStoreName?warehouseId="+row.warehouseId).then((resp) => {
			   					
			   					if (resp.data.coed == '2002') {
									console.log(resp)
									for(var i=0;i<resp.data.data.length;i++){
										this.ccc.push(parseInt(resp.data.data[i]))
									}
			   						
			   					}
			   				})
			   
		   },
		   addProperty(){
			   this.addHouseParam.num=this.aaa;
			   this.$http.post("/pawnbackgroundsystem/warehouse/insertHouse",this.addHouseParam).then((resp) => {
			   					
			   					if (resp.data.coed == '2002') {
			   						this.addHouse=false;
									this.selectAll();
			   					}
			   				})
		   },
		   testChange(){
			   this.add
			 console.log(this.aaa)  
		   },
		   getStoreName(){
			   this.$http.get("/pawnbackgroundsystem/store/GetStoreNameDto").then((resp) => {
			   					
			   					if (resp.data.coed == '2002') {
			   						this.bigSorts=resp.data.data;
			   					}
			   				})
		   },
		   insertHouse(){
			   this.$http.post("/pawnbackgroundsystem/warehouse/insertHouse",this.addHouseParam).then((resp) => {
			   					
			   					if (resp.data.coed == '2002') {
			   						this.$message({
			   							message: '删除成功',
			   							type: 'success'
			   						});
			   						this.selectAll();
			   					}
			   				})
		   },
		   delHouse(houseId){
			   console.log(houseId);
			   this.$http.get("/pawnbackgroundsystem/warehouse/delWarehouse?houseId="+houseId).then((resp) => {
			   					
			   					if (resp.data.coed == '2002') {
			   						this.$message({
			   							message: '删除成功',
			   							type: 'success'
			   						});
			   						this.selectAll();
			   					}
			   				})
		   },
		   forcode(row){
			   return row.warehouseStatus==1?'停用':'启用';
		   },
		   selectAll(){
			   console.log("-------------")
			   console.log(this.selectHouse)
			   this.$http.post("/pawnbackgroundsystem/warehouse/getAllWareHouse",this.selectHouse).then((resp) => {
			   					
			   					if (resp.data.coed == '2002') {
			   						this.tableData=resp.data.data.lg;
									this.total=resp.data.data.totle;
									this.currentPage=resp.data.data.indePage;
			   					}
			   				})
		   },
		   getAll(){
			   // this.addtask=true;
			   // this.$http.get("/pawnbackgroundsystem/warehouse/getAllHouse").then((resp) => {
			   					
			   // 					if (resp.data.coed == '2002') {
			   // 						this.bigSorts=resp.data.data;
			   // 					}
			   // 				})
			   
		   },
		   input(){},
		   clearfrom(){
			   this.updeteHouseParam.warehouseName=null,
			   this.updeteHouseParam.warehousePeople=null,
			   this.updeteHouseParam.warehousePhone=null,
			   this.updeteHouseParam.warehouseAddress=null,
			   this.updeteHouseParam.warehouseStatus=null,
			   this.updeteHouseParam.num=null,
			   this.ccc=null,
			
			 this.addHouseParam={
				warehouseName: null,
				warehousePeople: null,
				warehousePhone: null,
				warehouseAddress: null,
				warehouseStatus:null,
				num:[]
			}  
			   
		   },
		   
		   delProperty(){},
		  
	     toggleSelection(rows) {
	       // if (rows) {
	       //   rows.forEach(row => {
	       //     this.$refs.multipleTable.toggleRowSelection(row);
	       //   });
	       // } else {
	       //   this.$refs.multipleTable.clearSelection();
	       // }
	     },
	     handleSelectionChange(val) {
	       // this.multipleSelection = val;
	     },
			  onSubmit(){
				  
			  }
	   },
	   created(){
		   this.getStoreName()
		   this.selectAll();
	   }
  }
</script>

<style scoped>

</style>

